package com.itheima.web.controller;

import com.itheima.web.manager.UserManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    private UserManager userManager;

    @GetMapping("/manage/users")
    public ResponseEntity findUsersByPage(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pagesize) {

        return userManager.findUsersByPage(page, pagesize);
    }

    @GetMapping("/manage/users/{userId}")
    public ResponseEntity findUserInfoById(@PathVariable Long userId) {
        return userManager.findUserInfoById(userId);
    }

    @GetMapping("/manage/messages")
    public ResponseEntity findMessages(@RequestParam(defaultValue = "1") Integer page,
                                           @RequestParam(defaultValue = "10") Integer pagesize,
                                           Long uid, Integer state) {
        return userManager.findMessages(uid,state,page,pagesize);
    }


    @GetMapping("/manage/messages/{publishId}")
    public ResponseEntity findMovementVoById(@PathVariable String publishId) {
        return userManager.findMovementVoById(publishId);
    }

    @GetMapping("/manage/messages/comments")
    public ResponseEntity findCommentById(@RequestParam(defaultValue = "1") Integer page,
                                       @RequestParam(defaultValue = "10") Integer pagesize,
                                       String messageID) {
        return userManager.findCommentById(page,pagesize,messageID);
    }

    @GetMapping("/manage/videos")
    public ResponseEntity findVideoById(@RequestParam(defaultValue = "1") Integer page,
                                          @RequestParam(defaultValue = "10") Integer pagesize,
                                        Long uid) {
        return userManager.findVideoById(page,pagesize,uid);
    }
}
